package cn.com.fattiger.framework.cms.admin.common.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import cn.com.fattiger.framework.cms.admin.common.model.Answer;



public interface AnswerRepository extends PagingAndSortingRepository<Answer, Long> {
	
	@Query(getOptionCount)
	List<Answer> getOptionCount(Long questionId);
	final String getOptionCount = "select b.content as optionValue, count(a.optionIds) as optionCount from Answer a, Option b where a.optionIds = b.id and a.questionId = ?1 and b.content != '其他' group by a.optionIds ORDER BY count(a.optionIds) DESC";
}
